from django.http import HttpResponse

#from .models import first,remark
from . import models
def insert_remark(request):
   # test = remark(name='June',message='just test',dz_num = 666)
   # test.save()
   # return HttpResponse("insert ok !!!")
   if (request.GET != ''):
      new_remark = models.remark(follow_id=request.GET['follow_id'],message=request.GET['message'])
      new_remark.save()
#      print('=======================')
#      print('follow_id : ',type(request.GET['follow_id']))
#      print('=======================')
      return HttpResponse("insert remark ok!")
   else:
      return HttpResponse("insert remark fail!")

def insert_first(request):
   # test = r(name='June',message='just test',dz_num = 666)
   # test.save()
   # return HttpResponse("insert ok !!!")
   if (request.GET != ''):
      new_first = models.first(name=request.GET['name'],message=request.GET['message'])
      new_first.save()
#      print('=======================')
#      for var in request.GET:
#         print(var,' : ',request.GET[var])
#      print('=======================')
      return HttpResponse("insert first ok!")
   else:
      return HttpResponse("insert first fail!")

def insert_lc(request):
     if 'id' in request.GET:
       sss=models.first.objects.get(id=request.GET['id'])
       sss.like_count=sss.like_count+1
       sss.save()
#      if request.GET['number']==1:
#        response ={'message':'点赞成功'}
#      else:
#        response ={'message':'取消点赞成功'}
       return HttpResponse("点赞成功")
     else:
#       response ={'message':'id错误'}
       return HttpResponse("id异常")

